#pragma once

// Copyright (c) 2010 Manuel Peinado Gallego <manuel.peinado@gmail.com>
// Distributed under the MIT license

// WorldFollower.h : interface of the WorldFollower class
//

#include "NodeManager.h"
#include "MaterialManager.h"
#include "ShaderManager.h"
#include "ShaderEvent.h"
#include "TextureManager.h"
#include "MeshManager.h"
#include <alg3d/alg3d.h>
class World;

// ----------------------------------------------------------------------------
// Class "WorldFollower"
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
//
// ----------------------------------------------------------------------------

class WorldFollower : public NodeListener,
                      public MaterialListener,
                      public ShaderListener,
                      public MeshListener,
                      public TextureListener
{
public:

    // Constructor flags
    enum 
    {
        ListenNothing = 0,
        IsNodeListener = 1, 
        IsMaterialListener = 2,
        IsShaderListener = 3,
        IsTextureListener = 4,
        IsMeshListener = 5
    };


    WorldFollower(int flags);
    virtual ~WorldFollower();

    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    // There must be a World attached, otherwise an assertion fails (debug 
    // mode only)
    World& getWorld();
    
    // As a rule of thumb, call this before you do anything else with this
    // object. We don't make this a param. of the ctor. because that doesn't
    // play nicely with MFC
    void setWorld(World* world);

    // Don't call getWorld unless you're sure hasWorld returns true
    bool hasWorld() const;

    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

protected:

    // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  

    virtual void onWorldChanged(World* /*newWorld*/) {}

private:

    // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  

    // The world this view looks into
    World* m_world;

    // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  
    
    // Creation flags
    int m_flags;
};

